package com.cust.cow.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cust.cow.common.CowMatingLog;
import com.cust.cow.common.Result;
import com.cust.cow.pojo.cowCattle;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

@Mapper
public interface CowCattleMapper extends BaseMapper<cowCattle> {
    @Select("select * from cowCattle")
    public List<cowCattle> findCowCattleAll();

    @Insert("insert into cowCattle values(#{cattleId},#{productionStatus},#{matingNumber})")
    public int insertCowCattle(@RequestBody cowCattle cowCattle);

    @Delete("delete from cowCattle where cattle_id = #{cattleId}")
    public int deleteCowCattle(Integer cattleId);

    @Select("select c.cattle_id, c.breed_id, c.birthday, c.weight, c.sex,  m.mating_date,  cc.mating_number, cc.production_status,     c.quarantine_situation, c.remark from cow_cattle cc, mating_log m, cattle c where cc.cattle_id = m.cattle_id and cc.cattle_id = c.cattle_id and c.cattle_id = #{cattleId}")
    public CowMatingLog findCowCattleById(Integer cattleId);

    @Select("select c.cattle_id, c.breed_id, c.birthday, c.weight, c.sex,  m.mating_date,  cc.mating_number, cc.production_status,     c.quarantine_situation, c.remark from cow_cattle cc, mating_log m, cattle c where cc.cattle_id = m.cattle_id and cc.cattle_id = c.cattle_id")
    public List<CowMatingLog> findCowCattleMatingLogAll();
}
